package com.qf.bbapi.controller;

import com.qf.bbapi.config.SystemConfig;
import com.qf.bbapi.dto.OrderAddTypeDto;
import com.qf.bbapi.service.intf.OrderService;
import com.qf.bbapi.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/***
 * _ooOoo_
 * o8888888o
 * 88" . "88
 * (| -_- |)
 *  O\ = /O
 * ___/`---'\____
 * .   ' \\| |// `.
 * / \\||| : |||// \
 * / _||||| -:- |||||- \
 * | | \\\ - /// | |
 * | \_| ''\---/'' | |
 * \ .-\__ `-` ___/-. /
 * ___`. .' /--.--\ `. . __
 * ."" '< `.___\_<|>_/___.' >'"".
 * | | : `- \`.;`\ _ /`;.`/ - ` : | |
 * \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 * `=---='
 *          .............................................
 *           佛曰：bug泛滥，我已瘫痪！
 */

@RestController
@CrossOrigin
@Api(tags = "订单相关操作接口")
@RequestMapping("/api/order/")
public class OrderController {
    @Resource
    private OrderService orderService;

    @ApiOperation(value = "按订单状态查询接口")
    @GetMapping("selectByState")
    public R selectByState(HttpServletRequest request, Integer flag){
        return orderService.selectByState(request.getIntHeader(SystemConfig.TOKEN_HEADER),flag);
    }
    @ApiOperation(value = "修改订单状态接口")
    @PostMapping("updateState")
    public R updateState(HttpServletRequest request, Integer flag, String orderNo){
        return orderService.updateState(request.getIntHeader(SystemConfig.TOKEN_HEADER), flag, orderNo);
    }

    @PostMapping("orderSave.do")
    public R orderSave(HttpServletRequest request,@RequestBody OrderAddTypeDto dto){
        return orderService.orderSave(request.getIntHeader(SystemConfig.TOKEN_HEADER),dto);
    }
}
